package com.dg.cuckoo.admin.action.basicInformation;

import com.dg.cuckoo.admin.dto.basicInformation.userInfo.UserInfoDto;
import com.dg.cuckoo.admin.service.ProjectInfoServer;
import com.dg.cuckoo.admin.service.UserInfoService;
import com.dg.cuckoo.admin.vo.FreeVo;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 基本资料-用户信息
 */
@RestController
@RequestMapping("/basicInformation/userInfo")
public class UserInfo extends BaseController {

    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private ProjectInfoServer projectInfoServer;

    /**
     * 页面组织架构的信息
     */
    @PostMapping("organizationInfo")
    public JsonResult<String> organizationInfo() {
        String data = userInfoService.organizationInfo();
        return new JsonResult<>(OK, data);
    }

//    /**
//     * 点击显示组织架构二级标签
//     */
//    @PostMapping("tissueTwo")
//    public JsonResult<String> tissueTwo(String unitType){
//        String data = userInfoService.tissueTwo(unitType);
//        return new JsonResult<>(OK,data);
//    }
//
//    /**
//     * 点击组织架构三级标签
//     */
//    @PostMapping("tissueThree")
//    public JsonResult<List<UserInfoDto>> tissueThree(String unitType){
//        List<UserInfoDto> data = userInfoService.tissueThree(unitType);
//        return new JsonResult<>(OK,data);
//    }

    /**
     * 注册用户
     */
    @PostMapping("save")
    public JsonResult<Void> save(UserInfoDto dto) {
        userInfoService.save(dto);
        return new JsonResult<>(OK);
    }

    /**
     * 单击显示用户信息
     */
    @PostMapping("openUserInfo/{id}")
    public JsonResult<UserInfoDto> openUserInfo(@PathVariable String id){
        UserInfoDto data = userInfoService.openUserInfo(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 注销
     */
    @PostMapping("delect/{id}")
    public JsonResult<Void> delect(@PathVariable String id){
        userInfoService.delect(id);
        return new JsonResult<>(OK);
    }

    /**
     * 保存
     */
    @PostMapping("update/{id}")
    public JsonResult<Void> update(UserInfoDto dto,@PathVariable String id){
        userInfoService.update(dto,id);
        return new JsonResult<>(OK);
    }

    /**
     * 点击打开单位名称界面
     */
    @PostMapping("clickUnitInfo")
    public JsonResult<String> clickUnitInfo(){
        String data = projectInfoServer.clickUnitInfo();
        return new JsonResult<>(OK,data);
    }

//    /**
//     * 单位名称界面点击显示二级标签
//     */
//    @PostMapping("clickUnitTreeInfo")
//    public JsonResult<String> clickUnitTreeInfo(String unit){
//        String data = projectInfoServer.clickUnitTreeInfo(unit);
//        return new JsonResult<>(OK,data);
//    }



}
